
lobsterh5.main({
    data: {
        loading: false, //状态标记
        page: 1,
        perPage: 5,
        flag: true
    },
    //初始化页面
    pageload: function () {
        this.initevent();
        this.loadformlist();
    },
    //初始化事件
    initevent: function () {
        var self = this;

        //下拉加载数据
        $(document.body).infinite(100).on("infinite", function () {
            if (self.data.loading) return;
            self.data.loading = true;
            setTimeout(function () {
                self.data.page++;
                if (self.data.flag) {
                    self.loadformlist();
                }
                self.data.loading = false;
            }, 1000);
        });

    },
    loadformlist: function () {
        var self = this;

        $('.weui-loadmore').show();
        var param = { "page": self.data.page, "limit": self.data.perPage };
        lobsterh5.GETAPI("tsForm.getformlist_h5", param).then(res => {
            var data = res["data"];
            if (data.length < self.data.perPage) {
                self.data.flag = false//设置没有数据了标记
                $(document.body).destroyInfinite();
                $(".weui-loadmore").html("没有更多数据了");
            }
            $("#formlist").append(tpl(document.getElementById('tpl').innerHTML, { list: data }));

            //点击打开问卷
            $('.demo').unbind().click(function(){
                location.href= 'formwirte.html?appid=' + lobsterh5.GetAppId() + '&formid=' + $(this).attr('formid');
            })
        })
    }
}, false);